#pragma once

#include "CoreMinimal.h"
#include "Components/ShapeComponent.h"
#include "AutoShapeComponent.generated.h"

class UAutoShapeConfigBase;

/**
 * 
 */
UCLASS(Blueprintable, ClassGroup = "Collision", editinlinenew, hidecategories = (Object, LOD, Lighting, TextureStreaming), meta = (BlueprintSpawnableComponent))
class BASECLASS_API UAutoShapeComponent : public UShapeComponent
{
	GENERATED_BODY()

public:
	UAutoShapeComponent(const FObjectInitializer& ObjectInitializer);

protected:
	UPROPERTY(EditAnywhere, BlueprintReadWrite, Instanced, Category = "Config", meta = (DisplayPriority = 0, EditInlineNew))
	TObjectPtr<UAutoShapeConfigBase> ShapeConfig = nullptr;

public:
	//~ Begin UPrimitiveComponent Interface.
	virtual FPrimitiveSceneProxy* CreateSceneProxy() override;
	virtual bool IsZeroExtent() const override;
	virtual struct FCollisionShape GetCollisionShape(float Inflation = 0.0f) const override;
	virtual bool AreSymmetricRotations(const FQuat& A, const FQuat& B, const FVector& Scale3D) const override;
	//~ End UPrimitiveComponent Interface.

	//~ Begin USceneComponent Interface
	virtual FBoxSphereBounds CalcBounds(const FTransform& LocalToWorld) const override;
	virtual void CalcBoundingCylinder(float& CylinderRadius, float& CylinderHalfHeight) const override;
	//~ End USceneComponent Interface

	//~ Begin UShapeComponent Interface
	virtual void UpdateBodySetup() override;
	//~ End UShapeComponent Interface

	// Tool Func
public:
	bool InPrepareSharedBodySetup() { return PrepareSharedBodySetup<UAutoShapeComponent>(); }
	bool GetbUseArchetypeBodySetup() { return bUseArchetypeBodySetup; }
	void SetbUseArchetypeBodySetup(bool InbUseArchetypeBodySetup) { bUseArchetypeBodySetup = InbUseArchetypeBodySetup; }

	template <typename ShapeElemType>
	void InCreateShapeBodySetupIfNeeded() { CreateShapeBodySetupIfNeeded<ShapeElemType>(); }
};
